﻿using System.IO;
using System.Text.RegularExpressions;

namespace MikroGui
{
    public class NameIdPair
    {
        string _id;

        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }
        string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public NameIdPair(string id)
        {
            _id = id;
            _name = IdToCompanyName(id);
        }

        public static string IdToCompanyName(string id)
        {
            string match = @"^....([[:alnum:]]*)\d*";
            var m = Regex.Match(id, match);

            if (m.Success == true)
            {
                var g = m.Groups;
                return g[1].Value;
            }
            else // if no match return oryginal
            {
                return id;
            }
        }
    }

    public class Utilities
    {
        public static string AddCurrentDirPathToFileName(string fileName)
        {
            return Directory.GetCurrentDirectory() + @"\" + fileName;
        }

        public static string SingleQuoteString(string s)
        {
            return @"'" + s + @"'";
        }

        public static string DoubleQuoteString(string s)
        {
            return "\"" + s + "\"";
        } 
    }




}
